/*
 * Copyright 2009 Andreas Borglin andreas.borglin@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package borge.mobile.lib.pimp;

import java.io.InputStream;
import java.io.OutputStream;

/**
 * Interface for manipulating image data.
 * A provider implements this and contains the logic
 * to perform the actual operations
 * @author Andreas Borglin
 */
interface ImageEffectProvider extends ImageConstants {

    // Undo modes for space and performance reasons..
    public static final boolean UNDO_ENABLED = true;
    public static final boolean UNDO_DISABLED = false;
    public static final int FLIP_BOTH = 3; // For internal use only
    
    // Initialize underlying framework. Let it throw any exception.
    public void initialize(String format, String inputUrl, OutputStream os) throws Exception;
    public void initialize(String format, InputStream is, OutputStream os) throws Exception;
    public void setImageCreator(ImageCreator ic);
    public void close();
    public String[] getSupportedInputFormats();
    public String[] getSupportedOutputFormats();
    
    public void performOperation(int op, int a1, int a2, int a3, int a4) throws ImageEffectException; // No var-args in 1.3 :-(
    public void addOverlayImage(InputStream is, int x, int y, int order) throws ImageEffectException;
    public void removeOverlayImage(int order) throws ImageEffectException;
    public void rotateAndScale(int rot, int newWidth, int newHeight) throws ImageEffectException;
    
    public void reset() throws ImageEffectException;
    public void applyChanges() throws ImageEffectException;
    
    public void setOutputFormat(String format) throws ImageEffectException;
    public byte[] getCurrentImageData();
    public int getImageWidth();
    public int getImageHeight();
    public ImageSupport getImageSupport();
    
    public boolean canUndo();
    public boolean undo();
    public boolean redo();
    
    // Internal method for initializing image
    public void scaleAndRotate(int w, int h, int rot) throws Exception;
 
}
